#! /usr/bin/env python 
#coding=utf-8
from flask import jsonify
from flask_restful import marshal


def to_json(fields,data):
    value=marshal(data,fields)
    return jsonify(data=value)

def to_sucess(data,code):
    msg=''
    if code==1:
        msg='操作成功'
    else:
        msg = '操作失败'
    #value = marshal(data, fields)
    return jsonify(msg=msg,data=data,code=code)